<?php
//connect to database
include('config.inc.php');
$conn = mysql_connect($config['host'], $config['user'], $config['pass']);
mysql_selectdb($config['db'], $conn);

// Connecting to the database.
function getDB() {
	try {
		include('config.inc.php');
		$db = new PDO("mysql:host=".$config['host'].";dbname=".$config['db'], $config['user'], $config['pass']);
	}
	catch(Exception $e) {
		echo $e->getMessage();
	}
	return $db;
}

function checkLoggedin()
{
	session_start();
	if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true)
	{/*if logged in, do nothing */
		return true;
	}
	else
	{
	    $_SESSION["loggedin"] = false;
	    return false;
	}
}
?>